<template>
  <el-card shadow="never" class="aui-card--fill">
    <div class="mod-eightapp__einoticeinfo}">
      <el-form :inline="true" :model="dataForm" @keyup.enter.native="getDataList()">
        <el-form-item>
          <el-input v-model="dataForm.id" placeholder="id" clearable></el-input>
        </el-form-item>
        <el-form-item>
          <el-button @click="getDataList()" icon="el-icon-search"></el-button>
        </el-form-item>
        <el-form-item>
          <el-button type="success" @click="exportHandle()" >{{ $t('export') }}</el-button>
        </el-form-item>
        <el-form-item>
          <el-button v-if="$hasPermission('eightapp:einoticeinfo:save')" type="primary" icon="el-icon-plus" @click="addOrUpdateHandle()"></el-button>
        </el-form-item>
        <el-form-item>
          <el-button v-if="$hasPermission('eightapp:einoticeinfo:delete')" type="danger" icon="el-icon-delete" @click="deleteHandle()"></el-button>
        </el-form-item>
      </el-form>
      <el-table v-loading="dataListLoading" :data="dataList" border @selection-change="dataListSelectionChangeHandle" style="width: 100%;">
        <el-table-column type="selection" header-align="center" align="center" width="50"></el-table-column>
        <el-table-column prop="id" label="公告编号" header-align="center" align="center"></el-table-column>
        <el-table-column prop="type" label="公告类型" header-align="center" align="center" :formatter="noticeFormatter"></el-table-column>
        <el-table-column prop="noticeTime" label="发布时间" header-align="center" align="center"></el-table-column>
        <el-table-column prop="content" label="内容" header-align="center" align="center"></el-table-column>
        <el-table-column prop="managerId" label="物业管理员编号" header-align="center" align="center"></el-table-column>
        <el-table-column prop="ownerId" label="业主编号" header-align="center" align="center"></el-table-column>
        <el-table-column prop="creator" label="建表人" header-align="center" align="center"></el-table-column>
        <el-table-column prop="createTime" label="建表时间" header-align="center" align="center"></el-table-column>
        <el-table-column prop="updator" label="更新人" header-align="center" align="center"></el-table-column>
        <el-table-column prop="updateTime" label="更新时间" header-align="center" align="center"></el-table-column>
        <el-table-column prop="villageId" label="小区编号" header-align="center" align="center"></el-table-column>
        <el-table-column :label="$t('handle')" fixed="right" header-align="center" align="center" width="150">
          <template slot-scope="scope">
            <el-button v-if="$hasPermission('eightapp:einoticeinfo:update')" size="small" @click="addOrUpdateHandle(scope.row.id)" type="primary" icon="el-icon-edit" circle></el-button>
            <el-button v-if="$hasPermission('eightapp:einoticeinfo:delete')" size="small" @click="deleteHandle(scope.row.id)" type="danger" icon="el-icon-delete" circle></el-button>
          </template>
        </el-table-column>
      </el-table>
      <el-pagination
        :current-page="page"
        :page-sizes="[10, 20, 50, 100]"
        :page-size="limit"
        :total="total"
        layout="total, sizes, prev, pager, next, jumper"
        @size-change="pageSizeChangeHandle"
        @current-change="pageCurrentChangeHandle">
      </el-pagination>
      <!-- 弹窗, 新增 / 修改 -->
      <add-or-update v-if="addOrUpdateVisible" ref="addOrUpdate" @refreshDataList="getDataList"></add-or-update>
    </div>
  </el-card>
</template>

<script>
import mixinViewModule from '@/mixins/view-module'
import AddOrUpdate from './einoticeinfo-add-or-update'
export default {
  mixins: [mixinViewModule],
  data () {
    return {
      mixinViewModuleOptions: {
        getDataListURL: '/eightapp/einoticeinfo/page',
        getDataListIsPage: true,
        exportURL: '/eightapp/einoticeinfo/export',
        deleteURL: '/eightapp/einoticeinfo',
        deleteIsBatch: true
      },
      dataForm: {
        id: ''
      }
    }
  },
  components: {
    AddOrUpdate
  },
  methods:{
    noticeFormatter(row) {
      var type = row.type;
      if (type == 0) {
        return "缴费公告";
      } else if (type == 1) {
        return "生活公告";
      } else if (type == 2) {
        return "安全公告";
      } else if (type == 3) {
        return "其他公告";
      }
    },
  }
}
</script>
